home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr1.arc / STRRCHR.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  852b  |  28 lines

  1. /*  File   : strrchr.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 10 April 1984
  4.     Defines: strrchr(), rindex()
  5.  
  6.     strrchr(s, c) returns a pointer to the  last  place  in  s  where  c
  7.     occurs,  or  NullS if c does not occur in s. This function is called
  8.     rindex in V7 and 4.?bsd systems; while not ideal the name is clearer
  9.     than strrchr, so rindex  remains  in  strings.h  as  a  macro.   NB:
  10.     strrchr  looks  for single characters, not for sets or strings.  The
  11.     parameter 'c' is declared 'int' so it will go in a register; if your
  12.     C compiler is happy with register char change it to that.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. char *strrchr(s, c)
  18.     register _char_ *s;
  19.     register int c;
  20.     {
  21.        register char *t;
  22.  
  23.        t = NullS;
  24.        do if (*s == c) t = s; while (*s++);
  25.        return t;
  26.     }
  27.  
  28.